﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EstateAdd.aspx.cs" Inherits="ZLDC.Estate.TM.EstateAdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新增楼盘</title>
    <base target="_self" />
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../js/jquery/style/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />   
        
</head>
<body>
    <form id="form1" action="../Handler/HandlerIndex.ashx?act=estate_save" enctype="multipart/form-data"
    method="post">
    <div style="height: 4px;">
    </div>
    <!-- info主表信息 -->
    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr>
            <td height="30" bgcolor="#f7f7f7" class="button1" style="padding-left: 10px;">
                <img src="../images/zlTitle.gif" width="13" align="absmiddle" />
                <span id="spanTitle"></span>                
            </td>
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td>
                <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            所在区域：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <select id="sCity1" name="sCity1" style="width: 60px;" runat="server" onchange="return loadCity('sCity1', 'sCity2')">
                            </select>
                            <select id="sCity2" name="sCity2" style="width: 60px;" runat="server" onchange="return loadCity('sCity2', 'sCity3')">
                            </select>
                            <select id="sCity3" name="sCity3" style="width: 60px;" runat="server">
                            </select><font color="red">*</font>
                            <input id="hCityId" name="hCityId" type="hidden" />
                            <input id="hAreaId" name="hAreaId" type="hidden" />
                        </td>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            总 户 数：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iFamilyTotal" name="iFamilyTotal" type="text" value="" class="textdocdown"
                                style="width: 80%" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            楼盘名称：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iName" name="iName" type="text" value="" class="textdocdown" style="width: 80%" /><font color="red">*</font>
                        </td>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            建筑面积：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iConstructionArea" name="iConstructionArea" type="text" value="" class="textdocdown"
                                style="width: 80%" onkeyup="LexunJS.checkNum(this)" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            楼盘别名：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iOtherName" name="iOtherName" type="text" value="" class="textdocdown"
                                style="width: 80%;" />
                        </td>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            开 发 商：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iRealestateName" name="iRealestateName" type="text" value="" class="textdocdown"
                                style="width: 80%" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            物业地址：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iAddress" name="iAddress" type="text" value="" class="textdocdown" style="width: 80%" /><font color="red">*</font>
                        </td>
                        <td width="12%" align="right" bgcolor="#F7F7F7">
                            开发商电话：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iRealestateTel" name="iRealestateTel" type="text" value="" class="textdocdown"
                                style="width: 80%" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            物业用途：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <select id="sUsage" name="sUsage" runat="server" onchange="return sUsage_onchange('sUsage')">
                            </select>
                            <span id="spanRoad" style="display: none;">商铺路名:
                                <input id="iRoadName" name="iRoadName" type="text" value="" class="textdocdown" style="width: 52%" />
                            </span>
                            <font color="red">*</font>
                        </td>
                        <td width="10%" align="right" bgcolor="#F7F7F7" rowspan="3">
                            周围环境：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;" rowspan="3" style="width: 80%;
                            height: 70px">
                            <span id="spanAroundCondition" runat="server"></span>
                            <input id="hAroundCondition" name="hAroundCondition" type="hidden" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            物业类型：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <select id="sType" name="sType" runat="server">
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            物业公司：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iPropertyCompany" name="iPropertyCompany" type="text" value="" class="textdocdown"
                                style="width: 80%" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            物业电话：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iPropertyTel" name="iPropertyTel" type="text" value="" class="textdocdown"
                                style="width: 80%" />
                        </td>
                        <td width="10%" align="right" bgcolor="#F7F7F7" rowspan="3">
                            交通情况：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;" rowspan="3">
                            <textarea id="taTrafficCondition" name="taTrafficCondition" style="width: 80%; height: 70px"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            物业级别：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <select id="sPropertyLevel" name="sPropertyLevel" runat="server" >
                            </select>                            
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            入伙时间：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <%--<input id="iCompleteDate" name="iCompleteDate" class="textdocdown" onclick="WdatePicker()" style="width:120px;" />--%><input id="iCompleteDate" name="iCompleteDate" class="textdocdown" style="width:120px;" onblur="LexunJS.checkDate(this)" /> 如:2001-06-28
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            建筑结构：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iConstruction" name="iConstruction" type="text" value="" class="textdocdown"
                                style="width: 80%" />
                        </td>
                        <td width="10%" align="right" bgcolor="#F7F7F7" rowspan="3">
                            备 注：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;" rowspan="3">
                            <textarea id="taRemark" name="taRemark" style="width: 80%; height: 70px"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            销售均价：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iSalesFare" name="iSalesFare" type="text" value="" class="textdocdown"
                                style="width: 80%" onkeyup="LexunJS.checkNum(this)" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                            物 业 费：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                            <input id="iPropertyFare" name="iPropertyFare" type="text" value="" class="textdocdown"
                                style="width: 80%" onkeyup="LexunJS.checkNum(this)" />
                        </td>
                    </tr>
                    <tr>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                        批地时间：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                        <input id="LeaseTime" name="LeaseTime" class="textdocdown" style="width:120px;" onblur="LexunJS.checkDate(this)" /> 如:2001-06-28
                        </td>
                        <td width="10%" align="right" bgcolor="#F7F7F7">
                        停车位：
                        </td>
                        <td width="40%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                        
                            <input id="park" name="park" type="text" value="" class="textdocdown"
                                style="width: 80%"  /></td>
                        
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <div style="padding-top: 15px; cursor: pointer; text-align: center;">        
        <input id="btnOk"    class="button_bak2" type="button" value="保存" onclick="return submitOK(0)" />   
        
        
        <input id="btnSave"  class="button_bak2" type="button" value="保存并新增栋阁"   onclick="return submitOK(1);" />   
        <input id="btnBatch"  class="button_bak2" type="button" value="批量添加栋阁房号"   onclick="return submitOK(2);" />   

    </div>
    <br />
    <input id="hID" name="hID" type="hidden" />
    <input id="ActionType" name="ActionType" type="hidden" />
    <input id="CommandId" name="CommandId" type="hidden" />
    
    </form>

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/jquery/jquery.hiAlerts-min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">

        $(document).ready(function() {
            var id = LexunJS.GetQueryString("id");
            var typeid = LexunJS.GetQueryString("typeid");  // 1直接添加 2申请添加
            document.getElementById("CommandId").value = typeid;
            if (typeid == 1)
                if (id > 0) {
                $("#spanTitle").html("<a href=\"EstateManager.aspx\">楼盘列表</a><span class=\"hbdot\">&raquo;</span> 修改楼盘");
                document.getElementById("btnSave").style.display = "none";
                } else {
                $("#spanTitle").html("<a href=\"EstateManager.aspx\">楼盘列表</a><span class=\"hbdot\">&raquo;</span> 添加楼盘");
                }
            else
                $("#spanTitle").html("<a href=\"EstateAddIsValid.aspx\">待审楼盘</a><span class=\"hbdot\">&raquo;</span> 申请楼盘");

            // 修改
            if (id > 0)

                showDetail(id);

        });

        // 查询详细
        function showDetail(id) {
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerIndex.ashx',
                data: 'act=estate_detail&id=' + id,
                timeout: '10000',
                error: function() {
                    alert("查询详情失败！");
                }, success: function(json) {
                    showDetailCallBack(json);
                }
            });
        }
        function showDetailCallBack(response) {
            var json = eval("(" + response + ")");
            var record = json.record;

            if (record == null || record.length == 0)
                return;

            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {
                $("#hID").val(record[i].id);
                $("#hCityId").val(record[i].cityid);
                $("#hAreaId").val(record[i].areaid);
                
                document.getElementById("sCity2").options[0].value = record[i].cityid;
                document.getElementById("sCity2").options[0].text = record[i].cityname;                
                document.getElementById("sCity3").options[0].value = record[i].areaid;
                document.getElementById("sCity3").options[0].text = record[i].areaname;

                $("#iName").val(record[i].name);
                $("#iOtherName").val(record[i].othername);
                $("#iAddress").val(record[i].address);
                $("#hAroundCondition").val(record[i].aroundcondition);
                $("#sUsage").val(record[i].usage);
                if (record[i].usage == "商铺") {
                    $("#spanRoad").show();
                    $("#iRoadName").val(record[i].roadname);
                }
                $("#sType").val(record[i].type);
                $("#iPropertyCompany").val(record[i].propertycompany);
                $("#taDescription").val(record[i].description);
                $("#iPropertyTel").val(record[i].propertytel); 
                $("#sPropertyLevel").val(record[i].propertylevel);                               
                $("#iCompleteDate").val(record[i].completedate);                
                $("#taTrafficCondition").val(record[i].trafficcondition);
                $("#iConstructionArea").val(record[i].constructionarea);
                $("#iFamilyTotal").val(record[i].familytotal);
                $("#iConstruction").val(record[i].construction);
                $("#taRemark").val(record[i].remark);
                $("#iSalesFare").val(record[i].salesfare);
                $("#iPropertyFare").val(record[i].propertyfare);
                $("#iRealestateName").val(record[i].realestatename);
                $("#iRealestateTel").val(record[i].realestatetel);
            }
        }

        // 选择周围环境
        function selectedRadio(obj) {
            var objValue = obj.value;

            if (obj.checked)
                LexunJS.addOrCutData(1, "hAroundCondition", objValue);
            else
                LexunJS.addOrCutData(0, "hAroundCondition", objValue);
        }

        // 级联加载列表
        function loadCity(sCity1, sCity2) {
            var parentid = document.getElementById(sCity1).value;

            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerIndex.ashx',
                data: 'act=area_list&parentid=' + parentid,
                timeout: '10000',
                error: function() {
                    alert("修改失败！");
                }, success: function(json) {
                    loadCity2CallBack(json, sCity2);
                }
            });
        }

        // 加载城市列表回调
        function loadCity2CallBack(response, sCity2) {
            var json = eval("(" + response + ")");
            var record = json.record;

            $("#" + sCity2).html("");
            var obj = document.getElementById(sCity2);
            if (record == null || record.length == 0) {
                LexunJS.selectAddOption(obj, "无", 0);
                return;
            }

            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {
                var sName = record[i].name;
                var sValue = record[i].id;

                LexunJS.selectAddOption(obj, sName, sValue);
            }
        }

        // 提交前验证
        function submitOK(obj) {
            document.getElementById("ActionType").value = obj; ///操作类型，0-保存楼盘信息，1保存并新增栋阁
            var cityId = $("#sCity2").val();
            if (cityId == "请选择") {
                cityId = "0";
             }
             var areaId = $("#sCity3").val();
             if (areaId == "请选择") {
                 areaId = "0";
             }

            $("#hCityId").val(cityId);
            $("#hAreaId").val(areaId);

            if (parseInt(areaId) <= 0) {
                alert("必须选择片区！");
                return false;
            }

            var name = document.getElementById("iName").value;
            if (name == "") {
                alert("楼盘名称不能为空！");
                document.getElementById("iName").focus();
                return false;
            }

            var address = document.getElementById("iAddress").value;
            if (address == "") {
                alert("物业地址不能为空！");
                document.getElementById("iAddress").focus();
                return false;
            }

            var objtext = LexunJS.GetSelectText("sUsage");
            if (objtext == "请选择") {
                alert("请选择用途!");
                return false;
             }
           
            if (objtext == "商铺") {
                var roadname = document.getElementById("iRoadName").value;
                if (roadname == "") {
                    alert("商铺路名不能为空！");
                    document.getElementById("iRoadName").focus();
                    return false;
                }
            }

            // 总户数
            //var familyTotal = document.getElementById("iFamilyTotal").value;           

            document.forms[0].submit();
        }

        // 选择物业类型
        function sUsage_onchange(objname) {
            var objtext = LexunJS.GetSelectText(objname);
            var objspan = $("#spanRoad");

            if (objtext == "商铺")
                objspan.show();
            else
                objspan.hide();
        }
        
    </script>

</body>
</html>
